const express = require('express')
const app = express()
const mysql      = require('mysql');
const connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '123456',
  database : 'db'
});

connection.connect()

app.get('/', (req, res) => {
    connection.query('SELECT * FROM students', function (error, results, fields) {
        if (error) throw error;
        res.send(`the number of row is:  ${results.length}`)
    });
})

app.listen(3000, () => console.log('Example app listening on port 3000!'))